<?php

class IndexController extends Yaf_Controller_Abstract {

    public function ajaxAction() {

        //如果是Ajax请求, 可以关闭HTML视图输出，disableView() 会关闭视图模块，而 autoRender(false) 则只关闭视图输出:
        if ($this->getRequest()->isXmlHttpRequest()) {
            Yaf_Dispatcher::getInstance()->disableView();
            Yaf_Dispatcher::getInstance()->autoRender(false);
            echo 'ajax';
            exit;
        }
    }

    public function indexAction() {
        /**
        $db = Yaf_Registry::get('db');
        $data = [
            'id'     =>null,
            'name'   =>'abcd',
            'url'    =>'abcd',
            'alexa'  =>'50',
            'country'=>'abcd102',
        ];
        $db->insert('websites',$data);
        exit;
        */
        header('content-type:text/html;charset=utf-8');

        $model = new  SampleModel();

        $this->getView()->assign("content", "Hello World");

        $this->getView()->assign("list", $model->show());
//        //读取配置文件
//        $config = Yaf_Application::app()->getConfig();
//        //打印配置信息
//        echo '<pre>';
//        print_r($config);
//        echo '</pre>';
    }

    public function errorAction() {
        throw new \Exception('error demo',100110);
    }


}
?>